<?php
class JishuController extends DefaultModuleController {

	public function actionView() {
		$id = getgpc(2);
		
		$newsView = $this->JishuModel->find("articleId='$id' ",1,1000, 'id DESC');
		
		
		$newsDate = $this->JishuModel->updateByPk($id,array(
			'views'=>'+1'
		));
		
		$title = $newsView['title'];
		$content = $newsView['content'];
		$author = $newsView['author'];
		$source = $newsView['source'];
		$createdTime2 = date('Y-m-d', $newsView['createdTime']);
		
		$this->header['title'].=' - '.$title;
		$this->view->assign('title',$title);
		$this->view->assign('author',$author);
		$this->view->assign('source',$source);
		$this->view->assign('content',$content);
		$this->view->assign('createdTime2',$createdTime2);
		$this->view->assign('newsList',$newsView);
		$this->display('news_view');
	}
	
	public function actionList(){
		$page = intval(getgpc('page'));
		if (!$page) $page = 1;


		$sqladd = "categoryId='66' ";
		
		$wendasqladd = "categoryId='467' ";

		$newsList = $this->JishuModel->findAll($sqladd, $page, 6, 'createdTime DESC');
		foreach ($newsList as &$v){
			$v['createdTime2'] = date("Y-m-d",$v['createdTime']);
		}
		
		$wendaList = $this->JishuModel->findAll($wendasqladd, $page, 6, 'createdTime DESC');
		foreach ($wendaList as &$v){
			$v['createdTime2'] = date("Y-m-d",$v['createdTime']);
		}
		
		
		$num = $this->JishuModel->count($sqladd);
		$multipage = $this->page($num, GODHOUSE_PPP3, $page, 'news-list-'.$id.'.htm');
		
		$this->view->assign('id',$wendasqladd);
		$this->view->assign('multipage', $multipage);
		$this->view->assign('newsList',$newsList);
		$this->view->assign('wenList',$wendaList);

		$this->display('jishu_list');
	}
}